<?php
/**
 * Title:Modle Class Page
 * Times:2010.04.24
 * Author:雅典娜之子
 */

  !defined('ACCESSING') && exit('Forbidden');

class Page extends Base
{
	var $MaxPage;
	var $PageInfo;
	var $PageHtml;

	public function getPageStr($PSize,$PageNow,$MaxNum,$url) 
	{
		$this->MaxPage = $MaxNum / $PSize;
		if($MaxNum > $PSize){
			$this->MaxPage = intval(ceil($this->MaxPage));
			if(!is_numeric($PageNow)) exit("數值錯誤!!");
			if($PageNow >= $this->MaxPage){$PageNow = $this->MaxPage;}
			
			$this->PageHtml = "每頁 <span class='red'>".$PSize."</span> 筆記錄，總共有 <span class='red'>".$this->MaxPage."</span> 頁，現在第 <span class='red'>".$PageNow."</span> 頁 &nbsp; &nbsp; ";
			$this->PageHtml = $this->PageHtml."<a href='$url&page=1' class='weight'>首頁</a> \n";
			
			if($PageNow == 1){
				$this->PageHtml = $this->PageHtml."&nbsp; 上一頁&nbsp; \n";
			}else{
				$this->PageHtml = $this->PageHtml."&nbsp; <a href='$url&page=".($PageNow - 1)."' class='weight'>上一頁</a> &nbsp;\n";
			}
			
			if($PageNow == $this->MaxPage){
				$this->PageHtml = $this->PageHtml."&nbsp; 下一頁 &nbsp;\n";
			}else{
				$this->PageHtml = $this->PageHtml."&nbsp; <a href='$url&page=".($PageNow + 1)."' class='weight'>下一頁</a> &nbsp;\n";
			}
			
			$this->PageHtml = $this->PageHtml."&nbsp; <a href='{$url}&page=".$this->MaxPage."' class='weight'>末頁 &nbsp;</a>\n";
			$this->PageHtml = $this->PageHtml."<select name='jumpMenu' id='jumpMenu' onchange='MM_jumpMenu('parent',this,0)'>\n";
			for($i = 1;$i <= $this->MaxPage;$i++){
				$this->PageHtml = $this->PageHtml."	<option value='$url&page=$i'>$i</option>\n";
			}
			$this->PageHtml = $this->PageHtml."</select>";
			return $this->PageHtml;
		}
	}
}
?>